module.exports.resOut = function (response, head, data) {
    response.writeHead(head.code, {"Content-Type": "" + head.type + ";charset=" + head.charset});
    response.write(data);
    response.end();
};

module.exports.getType = function (extname) {
    switch (extname) {
        case '.html':
            return 'text/html';
        case '.css':
            return 'text/css';
        case '.js':
            return 'text/javascript';
        default:
            return 'text/html';
    }
};

module.exports.getMime = function (fs, extname) {
    let mimeStr = fs.readFileSync("./mime.json"); //同步方式读取文件
    let mimes = JSON.parse(mimeStr);
    return mimes[extname];
};